<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>使用jQuery完成复选框的全选和全不选</title>
		<script src="../../js/jquery-1.11.0.min.js"></script>
		<script>
			$(function () {
				$("#select").click(function () {
					var flag = $(this).prop("checked");
					$("input").prop("checked",flag);
				});
			});
		</script>
	</head>
	<body>
		<table border="1" width="500" height="50" align="center" id="tbl" >
			<thead>
				<tr>
					<td colspan="4">
						<input type="button" value="添加" />
						<input type="button" value="删除" />
					</td>
				</tr>
				<tr>
					<th><input type="checkbox" id="select"></th>
					<th>编号</th>
					<th>姓名</th>
					<th>年龄</th>
				</tr>
			</thead>
			<tbody align="center">
				<tr >
					<td><input type="checkbox" class="selectOne"/></td>
					<td>1</td>
					<td>张三</td>
					<td>22</td>
				</tr>
				<tr >
					<td><input type="checkbox" class="selectOne"/></td>
					<td>2</td>
					<td>李四</td>
					<td>25</td>
				</tr>
				<tr >
					<td><input type="checkbox" class="selectOne"/></td>
					<td>3</td>
					<td>王五</td>
					<td>27</td>
				</tr>
				<tr >
					<td><input type="checkbox" class="selectOne"/></td>
					<td>4</td>
					<td>赵六</td>
					<td>29</td>
				</tr>
				<tr >
					<td><input type="checkbox" class="selectOne"/></td>
					<td>5</td>
					<td>田七</td>
					<td>30</td>
				</tr>
				<tr >
					<td><input type="checkbox" class="selectOne"/></td>
					<td>6</td>
					<td>汾九</td>
					<td>20</td>
				</tr>
			</tbody>
		</table>
	</body>
</html>
